

	import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import java.util.Vector;

import org.logicalcobwebs.proxool.ProxoolException;
import org.logicalcobwebs.proxool.configuration.PropertyConfigurator;
	public class ProxoolConnectionManager {
	     static private ProxoolConnectionManager instance;
	     static synchronized public ProxoolConnectionManager getInstance() {
	         if (instance == null) {
	             instance = new ProxoolConnectionManager();
	         }
	         return instance;
	     }
	     private ProxoolConnectionManager() {
	         this.init();
	     }
	     public void freeConnection(String name, Connection con) {
	         try{
	             if(con!=null) con.close();
	         }catch(Exception ex){ex.printStackTrace();}
	     }
	     public Connection getConnection(String proxoolname) {
	         try {
	             return DriverManager.getConnection(proxoolname);
	         } catch (SQLException ex) {
	             return null;
	         }
	     }
	     public void release() {}
	     
	     private void init(){
	         try {
	             InputStream is = getClass().getResourceAsStream("proxool.properties");
	             Properties properties = new Properties();
	             properties.load(is);
	             PropertyConfigurator.configure(properties);
	         } catch (IOException ex) {
	             ex.printStackTrace();
	         } catch (ProxoolException e1) {
	             e1.printStackTrace();
	         }
	     }
	     
	     public Vector<String[]> SqlExcute(String poolname,String sqlString) {
	         Vector<String[]> rc = new Vector<String[]>();
	         int colCnt = 0;
	         ProxoolConnectionManager connmanager=null;
	         Connection conn = null;
			PreparedStatement pstam = null;
			ResultSet rs = null;
			try {
	             connmanager = ProxoolConnectionManager.getInstance();
	             conn = connmanager.getConnection(poolname); //此处应为你要使用的连接池的名称,如:proxool.WEBGIS或proxool.Navtech或proxool.Fee
	             pstam = conn.prepareStatement(sqlString);
	             rs = pstam.executeQuery();
	             colCnt = rs.getMetaData().getColumnCount();
	             while (rs.next()) {
	                 String[] tempStr = new String[colCnt];
	                 for (int i = 0; i < colCnt; i++) {
	                     tempStr[i] = rs.getString(i + 1);
	                     if (tempStr[i] == null) {
	                         tempStr[i] = "";
	                     }
	                 }
	                 rc.add(tempStr);
	             }
	         } catch (Exception e) {
	         } finally {
	             try {
	                 rs.close();
	                 pstam.close();
	             } catch (Exception e) {
	                 e.printStackTrace();
	             }
	             if (conn != null) {
	                 try {
	                     connmanager.freeConnection(poolname, conn);
	                 } catch (Exception e) {
	                     e.printStackTrace();
	                 }
	             }
	         }
	         return rc;
	     }
	}